<?
	//header('Content-type: text/html; charset= utf-8');?>
<!DOCTYPE html>
	<html lang="ru">
	<head>
		<meta charset="utf-8">
		<title>Золотое Время (Golden Time)</title>
		<? include'../library/core.php';
		$gamers_obj = new gamers();
		$users_obj = new users();
		$admin_obj = new admin();
		include'../library/class.location.php'; ?>
		<script type="text/javascript">
			var HTTP_HOST = '<?php echo HTTP_HOST; ?>';
		</script>
		
		 
		<script type="text/javascript" src="../template/js/jquery.js"></script>
		<script type="text/javascript" src="../template/js/core.js"></script>	
		<script type="text/javascript" src="../template/js/location.js"></script>
		<script type="text/javascript" src="../template/js/ajaxupload.js"></script>
        <script type="text/javascript" src="../template/js/script.js"></script>
		<script type="text/javascript" src="../template/js/jquery.Jcrop.js"></script>
		<!-- Load TinyMCE -->
<script type="text/javascript" src="../template/js/tiny_mce/jquery.tinymce.js"></script>
<script type="text/javascript">
	$().ready(function() {
	
		$('textarea.tinymce').tinymce({
			// Location of TinyMCE script
			script_url : '../template/js/tiny_mce/tiny_mce.js',

			// General options
			theme : "advanced",
			plugins : "autoresize,autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist",

			// Theme options
			theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect,|,code",
			theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview",
			theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,advhr,|,ltr,rtl,|,fullscreen",
			theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,|,forecolor,backcolor",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_statusbar_location : "bottom",
			theme_advanced_resizing : false,
			 mode : "textareas",
			// Example content CSS (should be your site CSS)
			content_css : "../template/css/tinymce.css",
			
			// Drop lists for link/image/media/template dialogs
			template_external_list_url : "lists/template_list.js",
			external_link_list_url : "lists/link_list.js",
			external_image_list_url : "lists/image_list.js",
			media_external_list_url : "lists/media_list.js", 
			
			// Replace values for the template plugin
			template_replace_values : {
				username : "Some User",
				staffid : "991234"
			}
		});
	});
</script>
<!-- /TinyMCE -->
		<script type="text/javascript">
  jQuery(function($){

    // How easy is this??
    $('#cropbox').Jcrop();

  });

</script>
		<link rel="stylesheet" href="../template/style.css" type="text/css" media="screen" />
		
		<link rel="stylesheet" href="../template/css/jquery.formstyler.css" type="text/css" media="screen" />
		
		<!--<link rel="stylesheet" href="../template/css/main.css" type="text/css" media="screen" />
		<link rel="stylesheet" href="../template/css/demos.css" type="text/css" media="screen" />
		
		<link rel="stylesheet" href="../template/css/jquery.Jcrop.css" type="text/css" media="screen"/>-->
	</head>
	<body>
		<header>	
			<div class="in_header">
				<div class="logo">
					<a href="../index.php" title="logo"><img src="../images/logo.png" alt="logo"/></a>
				</div>
				<nav>
					<ul>
					<? $menu = $admin_obj->in_menu();
						foreach($menu as $menuItem){
							echo '<li><a href="../page.php?idpage='.$menuItem['id'].'"title="'.$menuItem['title'].'">'.$menuItem['title'].'</a></li>';
						}
					?>
					</ul>
				</nav>
				</div>
		</header>
		<?php
			if (isset($_GET['action']) && ($_GET['action']=='exit')){	
				$core_obj->no_active($_SESSION['user']['id']);
				$core_obj->last_visited($_SESSION['user']['id']);
				if (!empty($_SESSION['user'])) :?>	
				<script type="text/javascript"> window.location.href = '../index.php'</script>			
			<? $_SESSION['user'] = array();
				endif;?>
			<?}	
			if (!isset($_SESSION['user']['id'])):?>	
				<script type="text/javascript"> window.location.href = '../index.php'</script>				
			<? endif;?>
	
	<section class="register">
		<? if (isset($_SESSION['user']['privilege'])and ($_SESSION['user']['privilege']<2)):?>
			<? if (isset($_GET['action'])):?>
			<nav class="menu_admin">
				<ul>
					<li><a href="profile.php?action=pyramid" title="Пирамида" <? if ($_GET['action']=='pyramid'):?> class="active" <? endif;?>>Пирамида</a></li>
					<li><a href="profile.php?action=cabinet" title="Кабинет" <? if ($_GET['action']=='cabinet'):?> class="active" <? endif;?>>Кабинет</a></li>
					<li><a href="profile.php?action=new_password" title="Новый пароль" <? if ($_GET['action']=='new_password'):?> class="active" <? endif;?>>Новый пароль</a></li>
					<li><a href="profile.php?action=child" title="Подчиненные" <? if ($_GET['action']=='child'):?> class="active" <? endif;?>>Подчиненные</a></li>
					<?php if ($_SESSION['user']['privilege'] == 0):?>
						<li><a href="profile.php?action=add_parent" title="Добавить родителя<" <? if ($_GET['action']=='add_parent'):?> class="active" <? endif;?>>Добавить родителя</a></li>
					<? endif;?>
					<? if (($_SESSION['user']['privilege']>0)and($_SESSION['user']['privilege']<3)):?>
						<li><a href="profile.php?action=add_child" title="Добавить потомка" <? if ($_GET['action']=='add_child'):?> class="active" <? endif;?>>Добавить потомка</a></li>
					
						<!--<li><a href="profile.php?action=distribute" title="Распределить" <? if ($_GET['action']=='distribute'):?> class="active" <? endif;?>>Распределить</a></li>
						-->
					<? endif;?>
					<li><a href="profile.php?action=message" title="Сообщения" <? if ($_GET['action']=='message'):?> class="active" <? endif;?>>Сообщения <? echo $users_obj->new_message($_SESSION['user']['id']);?></a></li>
					<li><a href="profile.php?action=trash" title="Корзина сообщений" <? if ($_GET['action']=='trash'):?> class="active" <? endif;?>>Корзина сообщений</a></li>
					<li><a href="profile.php?action=complain" title="Пожаловатса Администратору" <? if ($_GET['action']=='complain'):?> class="active" <? endif;?>>Администратор</a></li>
					
					<li><a href="profile.php?action=exit" title="Выход">Выход</a></li>
				</ul>
			</nav>
		<? endif;?>
		<? if (isset($_SESSION['user']['id']) and (isset($_GET['action'])) and(($_GET['action']=='cabinet'))):?>			
					
			<?$core_obj->is_active($_SESSION['user']['id']);
			  $core_obj->visited($_SESSION['user']['id']);
		endif; ?>
	
	<?php if (isset($_GET['action']) && ($_GET['action']=='add_child')) :?>
		
		<div class = "reg">
			<form action="" method="get">
				<p><label for="login">Логин</label><input type="text" name="login" id="login" maxlength="255"/></p>
				<p><label for="name">Имя</label><input type="text" name="name" id="name" maxlength="255"/></p>
				<p><label for="surname">Фамилия</label><input type="text" name="surname" id="surname" maxlength="255"/></p>		
				<p><label for="phone">Номер телефона</label><input type="text" name="phone" id="phone" maxlength="255"/></p>
				<p><label for="email">email</label><input type="text" name="email" id="email" maxlength="255"/></p>
				<p><label for="country">Страна</label><select name="country" id="country"><option value="0">Выберите страну...</option><?echo $location_obj->getCountries();?></select></p>
				<p><label for="city">Город</label><select name="city" id="city"><option value="0">Выберете город...</option></select></p>
				<input type="button" value="Добавить пользователя" id="add_other_user">
			</form>
		</div>
		<div class="parent">
			<? echo $gamers_obj->check_parent((int)$_SESSION['user']['id']);?>
		</div>
		<? endif;?>
		
		<?php if (isset($_GET['action']) && ($_GET['action']=='add_parent') && ($gamers_obj->is_gamer($_SESSION['user']['id']) == false)) :?>
			<div class="reg add_parent">
				<!--<form action="" method="get">-->
					<p><label for="id">id</label><input type="text" name="id" id="id" maxlength="255"/></p>
					<input type="button" value="Добавить родителя" id="add_parent">
				<!--</form>-->
			</div>				
		<? endif;?>


	<?php if (isset($_GET['action']) && ($_GET['action']=='select_parent') && isset($_GET['id_parent']) && isset($_GET['id_child'])):?>
	<?$res = $admin_obj->select_user($_GET['id_parent']);?>
		<div class="reg">
			<?$res = $admin_obj->select_user($_GET['id_parent']);
					$image = $users_obj->select_image($_GET['id_parent']);
					if ($image):?>
						<ul id="image-list">
							<li class="user_image"><img src="<?echo $users_obj->image($image);?>"/> </li>
						</ul>	
					<? endif;?>
			<form action="" method="post" class="reg">
				<p><label>Логин</label><input type="text" value="<? echo $res['login'];?>" readonly maxlength="255"/></p>
				<p><label>Имя</label><input type="text" value="<? echo $res['name'];?>" readonly maxlength="255"/></p>
				<p><label>Фамилия</label><input type="text" value="<? echo $res['surname'];?>" readonly maxlength="255"/></p>		
				<p><label>Номер телефона</label><input type="text" value="<? echo $res['phone'];?>" readonly maxlength="255"/></p>
				<p><label>email</label><input type="text" value="<? echo $res['email'];?>" readonly maxlength="255"/></p>
				<p><label>Страна</label><input type="text" value="<? echo $core_obj->value_country($res['country']);?>" readonly maxlength="255"/></p>
				<p><label>Город</label><input type="text" value="<? echo $core_obj->value_city_show($res['city']);?>" readonly maxlength="255"/></p>			
				<input type="button" value="Подтверждение" id="select_parent">
			</form>			
		</div>
	<? endif;?>
	
<? endif;?>
		
		
		
		<?if (isset($_SESSION['user']['privilege']) && ($_SESSION['user']['privilege']==3)):?>
			<? //$admin_obj = new admin();?>
			<!--<h3>Здраствуйте,<? //echo $_SESSION['user']['login'];?></h3>-->	
			<? if (isset($_SESSION['user']['id']) && (isset($_GET['action'])) && (($_GET['action']=='cabinet'))):?>				
			<!--<h3>Здраствуйте,<? //echo $_SESSION['user']['login'];?></h3>-->	
			<? endif;?>
			<? if (isset($_GET['action'])):?>
				<nav class="menu_admin">
				<ul>
					<li><a href="profile.php?action=pyramid" title="Пирамида" <? if ($_GET['action']=='pyramid'):?> class="active" <? endif;?>>Пирамида</a></li>
					<li><a href="profile.php?action=cabinet" title="Кабинет" <? if ($_GET['action']=='cabinet'):?> class="active" <? endif;?>>Кабинет</a></li>
					<li><a href="profile.php?action=new_password" title="Новый пароль" <? if ($_GET['action']=='new_password'):?> class="active" <? endif;?>>Новый пароль</a></li>
					<li><a href="profile.php?action=allpage" title="Все страницы" <? if ($_GET['action']=='allpage'):?> class="active" <? endif;?>>Все страницы</a></li>
					<li><a href="profile.php?action=alluser" title="Все пользователи" <? if ($_GET['action']=='alluser'):?> class="active" <? endif;?>>Пользователи</a></li>
					<li><a href="profile.php?action=child" title="Подчиненные" <? if ($_GET['action']=='child'):?> class="active" <? endif;?>>Подчиненные</a></li>
					
					<!--<li><a href="profile.php?action=wait_distr" title="Ожидают распределения" <?// if ($_GET['action']=='wait_distr'):?> class="active" <? //endif;?>>Ожидают распределения</a></li>
					<li><a href="profile.php?action=distribute" title="Распределить" <? //if ($_GET['action']=='add_child'):?> class="active" <? //endif;?>>Распределить</a></li>
					-->
					<li><a href="profile.php?action=only_reg" title="Зарегистрированы" <? if ($_GET['action']=='only_reg'):?> class="active" <? endif;?>>Зарегистрированы</a></li>
					<li><a href="profile.php?action=message" title="Сообщения" <? if ($_GET['action']=='message'):?> class="active" <? endif;?>>Сообщения <? echo $users_obj->new_message($_SESSION['user']['id']);?></a></li>
					<li><a href="profile.php?action=trash" title="Корзина сообщений" <? if ($_GET['action']=='trash'):?> class="active" <? endif;?>>Корзина сообщений</a></li>
					
					<li><a href="profile.php?action=exit" title="Выход">Выход</a></li>
				</ul>
			</nav>	
			<? endif;?>
	
		
		<?php if (isset($_GET['action']) && ($_GET['action']=='allpage') and (!isset($_GET['id_page']))):?>
			<h3>Cтатические страницы</h3>			
			<a href="profile.php?action=addpage" class="add_new" title="Добавить страницу">Добавить страницу</a>
				<?// echo($admin_obj->show_pages());
				if ($_SESSION['user']['privilege'] == 3)
				echo '<form action="" method="post"><p><input type="text" name="find_pages" id="find_pages" value="Поиск" class="find"  maxlength="255"/></p></form>';
			
			if (isset($_POST['find_pages']))
				echo $admin_obj->find_pages($_POST['find_pages']);
			else
				echo($admin_obj->show_pages());
		endif;?>
		
		<?php if (isset($_GET['action']) && ($_GET['action']=='alluser')):?>
			<h3>Все пользователи</h3>
			<a href="profile.php?action=adduser" class="add_new" title="Добавить пользователя">Добавить пользователя</a>
		<? 
			if ($_SESSION['user']['privilege'] == 3)
				echo '<form action="" method="post"><p><input type="text" name="find_users" id="find_users" value="Поиск" class="find"  maxlength="255"/></p></form>';
			
			if (isset($_POST['find_users']))
				echo $admin_obj->find_users($_POST['find_users']);
			else
				echo($admin_obj->show_users());
				//echo 'kdk'.$_POST['find_pages'];
		endif;?>
		
		<?php if (isset($_GET['action']) && ($_GET['action']=='adduser')):?>
		<h3>Добавить пользователя</h3>
		<div class = "reg">
			<form action="" method="get">
				<p><label for="login">Логин</label><input type="text" name="login" id="login" maxlength="255"/></p>
				<p><label for="password">Пароль</label><input type="password" name="password" id="password" maxlength="255"/></p>
				<p><label for="confirm">Подтверждение</label><input type="password" name="confirm" id="confirm" maxlength="255"/></p>		
				<p><label for="name">Имя</label><input type="text" name="name" id="name" maxlength="255"/></p>
				<p><label for="surname">Фамилия</label><input type="text" name="surname" id="surname" maxlength="255"/></p>		
				<p><label for="phone">Номер телефона</label><input type="text" name="phone" id="phone" maxlength="255"/></p>
				<p><label for="email">email</label><input type="text" name="email" id="email" maxlength="255"/></p>
				<p><label for="country">Страна</label><select name="country" id="country"><option value="0">Выберите страну...</option><?echo $location_obj->getCountries();?></select></p>
				<p><label for="city">Город</label><select name="city" id="city"><option value="0">Выберете город...</option></select></p>
				<p><label for="question">Контрольный вопрос</label><select name="question" id="question" maxlength="255"><option value="0" >Контрольный вопрос...</option><? echo $core_obj->getQuestion();?></select></p>
				<p><label for="response">Контрольный ответ</label><input type="text" name="response" id="response" maxlength="255"/></p>
				<p><label for="privilege">Привелегии</label>
				<select name="privilege" id="privilege">					
					<option value="0">Пользователь</option>
					<option value="1">Игрок</option>
					<option value="2">Администратор</option>
					<option value="3">Администратор</option>
				</select></p>
				<input type="button" value="add_user" id="add_user">
			</form>
		</div>
		<? endif;?>
		
		<?php if (isset($_GET['action']) && ($_GET['action']=='update_page')&&(isset($_GET['id_page']))):?>
			<div class="profile">
				<form action="" method="get">
					<p><label for="title_page">Заголовок</label><input type="text" name="title_page" id="title_page" value="<? $res = $admin_obj->select_pages($_GET['id_page']); echo $res['title'];?>" maxlength="255"/></p>
					<p><textarea id="elm1" name="elm1" rows="15" cols="80" style="max-width: 600px" class="tinymce">
							<?echo $res['content']?>
					</textarea></p>
					<p><label for="in_menu">Отображать в главном меню</label><input type="checkbox" name="in_menu" id="in_menu" value="0" <? if($res['in_menu']):?>checked<? endif;?> maxlength="255"/></p>
					<p><label for="seo_title">SEO Title</label><input type="text" name="seo_title" class="seo" id="seo_title" value="<?echo $res['seo_title'];?>" maxlength="255"/></p>
					<p><label for="seo_description">SEO Description</label><input type="text" name="seo_description" class="seo" id="seo_description" value="<?echo $res['seo_description'];?>" maxlength="255"/></p>
					<p><label for="seo_keywords">SEO Keywords</label><textarea class="seo" id="seo_keywords" name="seo_keywords">
						<?echo $res['seo_keywords']?>
					</textarea></p>				
					<p><input type="button" value="Редактировать" id="update_page"></p>
				</form>
			</div>
		<? endif;?>
		
		<?php if (isset($_GET['action']) && ($_GET['action']=='addpage')):?>
			<h3> Добавить страницу </h3>
			<div class="profile">
			<form action="" method="get">
				<p><label for="title_page">Заголовок</label><input type="text" name="title_page" id="title_page"  maxlength="255"/></p>
				<p><textarea id="elm1" name="elm1" rows="15" cols="80" style="max-width: 600px" class="tinymce">
						
				</textarea></p>
				<p><label for="in_menu">Отображать в главном меню</label><input type="checkbox" name="in_menu" id="in_menu" value="0" /></p>
				<p><label for="seo_title">SEO Title</label><input type="text" name="seo_title" class="seo" id="seo_title" value="" maxlength="255"/></p>
				<p><label for="seo_description">SEO Description</label><input type="text" name="seo_description" class="seo" id="seo_description" value="" maxlength="255"/></p>
				<p><label for="seo_keywords">SEO Keywords</label><textarea class="seo" id="seo_keywords" name="seo_keywords">
				</textarea></p>	
				<p><input type="button" value="Добавить" id="add_page"></p>
			</form>
			</div>
		<? endif; ?>
		
		<? if (isset($_GET['action']) and ($_GET['action']=='wait_distr') and (!isset($_GET['id_user']))):?>
			<h3> Пользователи, которые ожидают распределения</h3>
			<? echo $gamers_obj->wait_distr(); 
		endif;?>
		<? if (isset($_GET['action'])and($_GET['action']=='wait_distr') and (isset($_GET['id_user']))):?>
			<h3> Определить куратора для пользователя</h3>
				<? $res = $admin_obj->select_user($_GET['id_user']);?>				
				<div class="reg">
					<form action="" method="post" class="reg">
						<p><label for="upd_name">Имя</label><input type="text" value="<? echo $res['name'];?>" name="upd_name" id="upd_name" maxlength="255"/></p>
						<p><label for="upd_surname">Фамилия</label><input type="text" value="<? echo $res['surname'];?>" name="upd_surname" id="upd_surname" maxlength="255"/></p>		
						<p><label for="upd_phone">Номер телефона</label><input type="text" value="<? echo $res['phone'];?>" name="upd_phone" id="upd_phone" maxlength="255"/></p>
						<p><label for="upd_email">email</label><input type="text" value="<? echo $res['email'];?>" name="upd_email" id="upd_email" readonly maxlength="255"/></p>
						<p><label for="upd_country">Страна</label><select name="upd_country" id="upd_country"><option selected value="<? echo $res['country'];?>"><? echo $core_obj->value_country( $res['country'])?></option><?php echo $location_obj->getCountries();?></select></p>
						<p><label for="upd_city">Город</label><select name="upd_city" class="pro" id="upd_city"><option value="<? echo $res['city'];?>"><? echo $core_obj->value_city($res['country'], $res['city'])?></option></select></p>
						<p><label for="upd_question">Контрольный вопрос</label><select name="upd_question" id="upd_question" maxlength="255"><option value="<? echo $res['question'];?>" checked="checked"><? echo $core_obj->value_question($_SESSION['user']['question'])?></option><?echo $core_obj->getQuestion()?></select></p>
						<p><label for="upd_response">Контрольный ответ</label><input type="text" value="<? echo $res['response'];?>" name="upd_response" id="upd_response" maxlength="255"/></p>
						<input type="button" value="Распределить" id="admin_distribute">
					</form>			
				</div>		
				<div class="parent">
					<?$result = $gamers_obj->select_pending($res['id']);?>
					<? echo $gamers_obj->check_parent($result);?>
				</div>
		<? endif;?>
		
		<? if (isset($_GET['action'])and($_GET['action']=='only_reg')and(!isset($_GET['id_user']))):?>
			<h3> Только зарегистрированные</h3>
			<? echo $gamers_obj->only_reg();
		endif; ?>
		
		<? if (isset($_GET['action'])and($_GET['action']=='only_reg')and(isset($_GET['id_user']))) :?>
			<h3>Выбрать родителя</h3>
			<?$res = $admin_obj->select_user($_GET['id_user']);?>
			<div class="reg">
				<?$res = $admin_obj->select_user($_GET['id_user']);
					$image = $users_obj->select_image($_GET['id_user']);
					if ($image):?>
						<ul id="image-list">
							<li class="user_image"><img src="<?echo $users_obj->image($image);?>"/> </li>
						</ul>	
					<? endif;?>
			<form action="" method="post" class="reg">
				<p><label>id</label><input type="text" id="id_user" name="id_user" value="<? echo $res['id'];?>" readonly maxlength="255"/></p>
				<p><label>Логин</label><input type="text" value="<? echo $res['login'];?>" readonly maxlength="255"/></p>
				<p><label>Имя</label><input type="text" value="<? echo $res['name'];?>" readonly maxlength="255"/></p>
				<p><label>Фамилия</label><input type="text" value="<? echo $res['surname'];?>" readonly maxlength="255"/></p>		
				<p><label>Номер телефона</label><input type="text" value="<? echo $res['phone'];?>" readonly maxlength="255"/></p>
				<p><label>email</label><input type="text" value="<? echo $res['email'];?>" readonly maxlength="255"/></p>
				<p><label>Страна</label><input type="text" value="<? echo $core_obj->value_country($res['country']);?>" readonly maxlength="255"/></p>
				<p><label>Город</label><input type="text" value="<? echo $core_obj->value_city_show($res['city']);?>" readonly maxlength="255"/></p>
				<p><label for="id_parent">id родителя</label><input type="text" name="id_parent" id="id_parent" value="" maxlength="255"/></p>
				<input type="button" value="Подтверждение" id="admin_add_parent">
			</form>			
		</div>
		<? endif;?>
		
		
		
		<?php if (isset($_GET['action']) && ($_GET['action']=='update_user')&&(isset($_GET['id_user']))):?>
		<h3> Редактировать данные о пользователе</h3>
		<?$res = $admin_obj->select_user($_GET['id_user']);
		  $res_gamers = $gamers_obj->about_gamer($_GET['id_user']);?>
		 
		<div class="reg">
			<?if ($res['is_active']):?>
				<p>Статус: Online</p>
			<? else: 
				if (($res['last_visit'])!='')
					echo 'Последнее посещение в '.date('H:m, j-m-y',$res['last_visit']);
				else
					echo 'Последнее посещение в ';
				$date = $res['last_visit'] - $res['visit'];
				echo '<p>Время пребыванья '.$core_obj->time_difference($date).'</p>';
				?>
				<p>Статус: Offline</p>
				<p>Уровень <? echo $res_gamers['layer'];?></p>
				<p> Платеж пользователю id=<? echo $res_gamers['next_parent'];?></p>
			<? endif; ?>
			<form action="" method="post" class="reg">
				<p><label for="upd_login">Логин</label><input type="text" value="<? echo $res['login'];?>" name="upd_login" id="upd_login" readonly maxlength="255"/></p>
				<p><label for="upd_name">Имя</label><input type="text" value="<? echo $res['name'];?>" name="upd_name" id="upd_name" maxlength="255"/></p>
				<p><label for="upd_surname">Фамилия</label><input type="text" value="<? echo $res['surname'];?>" name="upd_surname" id="upd_surname" maxlength="255"/></p>		
				<p><label for="upd_phone">Номер телефона</label><input type="text" value="<? echo $res['phone'];?>" name="upd_phone" id="upd_phone" maxlength="255"/></p>
				<p><label for="upd_email">email</label><input type="text" value="<? echo $res['email'];?>" name="upd_email" id="upd_email" readonly maxlength="255"/></p>
				<p><label for="upd_country">Страна</label><select name="upd_country" id="upd_country"><option selected value="<? echo $res['country'];?>"><? echo $core_obj->value_country( $res['country'])?></option><?php echo $location_obj->getCountries();?></select></p>
				<p><label for="upd_city">Город</label><select name="upd_city" class="pro" id="upd_city"><option value="<? echo $res['city'];?>"><? echo $core_obj->value_city($res['country'], $res['city'])?></option></select></p>
				<p><label for="upd_question">Контрольный вопрос</label><select name="upd_question" id="upd_question" maxlength="255"><option value="<? echo $res['question'];?>" checked="checked"><? echo $core_obj->value_question($res['question']);?></option><?echo $core_obj->getQuestion()?></select></p>
				<p><label for="upd_response">Контрольный ответ</label><input type="text" value="<? echo $res['response'];?>" name="upd_response" id="upd_response" maxlength="255"/></p>
				<p><label for="upd_privilege">Привелегии</label>
				<select name="upd_privilege" id="upd_privilege">					
					<option <? if ($res['privilege']==0):?>selected<? endif;?> value="0">Пользователь</option>
					<option <? if ($res['privilege']==1):?>selected<? endif;?> value="1">Игрок</option>
					<option <? if ($res['privilege']==2):?>selected<? endif;?> value="2">Менеджер</option>
					<option <? if ($res['privilege']==3):?>selected<? endif;?> value="3">Администратор</option>
				</select></p>	
				<p><label for="payd_admin">Оплачено</label><input type="checkbox" name="payd_admin" id="payd_admin" value="0" <?  if($gamers_obj->is_payd($_GET['id_user'])):?>checked<? endif;?> maxlength="255"/></p>
				
				<p><input type="button" value="На уровень выше" id="<? echo $res['id'];?>" class="level_plus">
				<input type="button" value="На уровень ниже" id="<? echo $res['id'];?>" class="level_minus"></p>
				<input type="button" value="Редактировать" id="upd_user">
			</form>			
		</div>
		<? endif;?>
		
		<? endif; ?>
		
		<?php if (isset($_GET['action']) && ($_GET['action']=='pyramid') ):?>
		<?
			$f2 = true;
			$f3 = true;				
			$mas_1 = $admin_obj->mas_1($_SESSION['user']['id']);				
			if (isset($mas_1)){
				$mas_2 = $admin_obj->mas_2($mas_1);
				for($i = 0; $i < count($mas_2); $i++)
				$n = count($mas_2);						 
				 for($i = 0; $i < $n; $i++){
					if( (isset($_GET['gamer_id'])) and($_GET['gamer_id'] == $mas_2[$i])){
						$f2 = false;
						break;
					}
				}
			}
			if (isset($mas_2)){
				$mas_3 = $admin_obj->mas_2($mas_2);
				$n = count($mas_3);			
					for($i = 0; $i < $n; $i++){					
					  if( (isset($_GET['gamer_id'])) and($_GET['gamer_id'] == $mas_3[$i])){				  
						$f3 = false;
						break;
					}
				}
			}
			$about_gamer = $gamers_obj->about_gamer($_SESSION['user']['id']);
			$layer = $about_gamer['layer'];
			$gamers_obj->next_parent($_SESSION['user']['id'],$layer);
			$permit = false;
					
			if ($layer == 1){
				$counter = count($mas_1);
				if ($counter == 3)
					$permit = true;
				for ($i = 0; $i < 3; $i++){
					if (isset($mas_1[$i]) and ($mas_1[$i]!=null))
						echo '<div class="green"></div>';
					if (!isset($mas_1[$i]) or ($mas_1[$i]==null))
						echo '<div class="red"></div>';					
				}
			}
			
			if ($layer == 2){
				$counter = count($mas_2);

				if ($counter == 9)
					$permit = true;
				for ($i = 0; $i < 9; $i++){
					if (isset($mas_2[$i]) and ($mas_2[$i]!=null))
						echo '<div class="green"></div>';
					if (!isset($mas_2[$i]) or ($mas_2[$i]==null))
						echo '<div class="red"></div>';					
				}
			}
			
			if ($layer == 3){
				$counter = count($mas_3);
				if ($counter == 27)
					$permit = true;
				for ($i = 0; $i < 27; $i++){
					if (isset($mas_2[$i]) and ($mas_2[$i]!=null))
						echo '<div class="green"></div>';
					if (!isset($mas_2[$i]) or ($mas_2[$i]==null))
						echo '<div class="red"></div>';					
				}
			}
			if ($_SESSION['user']['privilege'] == 3)
				echo '<form action="" method="post"><p><input type="text" name="find_pyramid" id="find_pyramid" value="Поиск по id" class="find"  maxlength="255"/></p></form>';
			
			$money_layer = $gamers_obj->money_layer($layer+1);
		/*?>
		<? */
			$payd_amount = 0;
			if ($about_gamer['layer'] == 1)
				$payd_amount = 3*LAYER1;
			if ($about_gamer['layer'] == 2)
				$payd_amount = 3*LAYER1+9*LAYER2;	
			if ($_SESSION['user']['privilege']!=3){
				echo '<h3>Вам заплатили '.$about_gamer['amount_paid'].'</h3>';
				echo '<h3>Вы сейчас на уровни '.$about_gamer['layer'].'</h3>';
				if ($about_gamer['amount_paid'])
				echo '<h3>Ваш куратор id='.$about_gamer['next_parent'].'</h3>';
			}
			if (($_SESSION['user']['privilege']!=3)and ($permit) and ($about_gamer['wait_money'] == 0) and ($about_gamer['payd']!=0) and ($about_gamer['amount_paid'] == $payd_amount)):?>
			
			<h3> Информация о платежах</h3>
			<div class="payment">
				<div class="reg">
					<?
						$next_id = $gamers_obj->next_parent($_SESSION['user']['id'],$layer);
						$res = $gamers_obj->dataParent($next_id);
						
					?>
					<span><p>Ваш следуючий платеж пользователю id=<? echo $res['id'];?></p></span>				
					<form action="" method="post" class="reg">
						<p><label for="upd_id">id</label><input type="text" value="<? echo $res['id'];?>" name="upd_id" id="upd_id" readonly maxlength="255"/></p>
						
						<p><label for="upd_login">Логин</label><input type="text" value="<? echo $res['login'];?>" name="upd_login" id="upd_login" readonly maxlength="255"/></p>
						<p><label for="upd_name">Имя</label><input type="text" value="<? echo $res['name'];?>" name="upd_name" id="upd_name" maxlength="255"/></p>
						<p><label for="upd_surname">Фамилия</label><input type="text" value="<? echo $res['surname'];?>" name="upd_surname" id="upd_surname" maxlength="255"/></p>		
						<p><label for="upd_phone">Номер телефона</label><input type="text" value="<? echo $res['phone'];?>" name="upd_phone" id="upd_phone" maxlength="255"/></p>
						<p><label for="upd_email">email</label><input type="text" value="<? echo $res['email'];?>" name="upd_email" id="upd_email" readonly maxlength="255"/></p>
						<p><label>Страна</label><input type="text" value="<? echo $core_obj->value_country($res['country'],$res['country']);?>" readonly maxlength="255"/></p>
						<p><label>Город</label><input type="text" value="<? echo $core_obj->value_city_show($res['city'])?>" readonly maxlength="255"/></p>	
						<p><label for="payd_admin">Участник прошел уровень</label><input type="checkbox" name="payd_admin" id="payd_admin" value="0" <?  if($gamers_obj->is_payd($res['id'])):?>checked disabled<? endif;?> maxlength="255"/></p>
					</form>	
							
						<form action="" method="post">
							<p><label for="amount_money">Сумма денег</label><input type="text" name="amount_money" id="amount_money" value="<? echo $money_layer;?>" maxlength="255"/></p>
							<!--<p><input type="button" value="Отправить заявку" id="money"/>--->
							<input type="button" value="Пожаловаться Администратору" id="complain_curator"/></p>							
						</form>
				</div>
			</div>
			
		<? 
			//$gamers_obj->check_wait_money($_SESSION['user']['id'],$money_layer);
			endif;?>
		
	
			
		<div class="pyramid">
			
		<? 	
			
		if ($_SESSION['user']['privilege']!=3){
			if (!isset($_GET['gamer_id']))
				$identuficator = $_SESSION['user']['id'];
			else
				$identuficator = $_GET['gamer_id'];				
			//if (isset($_GET['gamer_id']))
			{
			/*$mas_minus_1 = $gamers_obj->minus_level($identuficator);
			if (isset($mas_minus_1)){
				$mas_minus_2 = $gamers_obj->minus_level($mas_minus_1);
			}
			if (isset($mas_minus_2)){
				$mas_minus_3 = $gamers_obj->minus_level($mas_minus_2);						
			}*/
			$top = false;
			
				if ($top == false)
				if (isset($mas_1))
					for ($i=0;$i<count($mas_1);$i++){
						if ($identuficator == $mas_1[$i]){						
							$top = true;
							break;	
						}
					}
				if (($top == false) and ((isset($mas_2))))
					for ($i=0;$i<count($mas_2);$i++){
						if ($identuficator == $mas_2[$i]){
							$top = true;
							break;	
						}
					}
				if (($top == false) and ((isset($mas_3))))
					for ($i=0;$i<count($mas_3);$i++){
						if ($identuficator == $mas_3[$i]){
							$top = true;
							break;
						}
					}
				
				if ($top == false){
					$identuficator = $_SESSION['user']['id'];
					$_GET['gamer_id'] = $identuficator;
					/*$f2 = true;
				$f3 = true;				
				$mas_1 = $admin_obj->mas_1($_SESSION['user']['id']);
	
				if (isset($mas_1)){
					$mas_2 = $admin_obj->mas_2($mas_1);
					$n = count($mas_2);						 
					 for($i = 0; $i < $n; $i++){					
						 if( (isset($_GET['gamer_id'])) and($_GET['gamer_id'] == $mas_2[$i])){
							$f2 = false;
							break;
						}
					}
				}
				if (isset($mas_2)){
				$mas_3 = $admin_obj->mas_2($mas_2);
				$n = count($mas_3);			
					for($i = 0; $i < $n; $i++){					
					  if( (isset($_GET['gamer_id'])) and($_GET['gamer_id'] == $mas_3[$i])){				  
						$f3 = false;
						break;
					}
				}
			}
			$mas_minus_1 = $gamers_obj->minus_level($identuficator);
			if (isset($mas_minus_1)){
				$mas_minus_2 = $gamers_obj->minus_level($mas_minus_1);
			}
			if (isset($mas_minus_2)){
				$mas_minus_3 = $gamers_obj->minus_level($mas_minus_2);						
			}*/
				}
			}
			/*echo $f2;
			echo $f3;*/
			/*$f2 = true;
				$f3 = true;				
				$mas_1 = $admin_obj->mas_1($_SESSION['user']['id']);
	
				if (isset($mas_1)){
					$mas_2 = $admin_obj->mas_2($mas_1);
					$n = count($mas_2);						 
					 for($i = 0; $i < $n; $i++){					
						 if( (isset($_GET['gamer_id'])) and($_GET['gamer_id'] == $mas_2[$i])){
							$f2 = false;
							break;
						}
					}
				}
				if (isset($mas_2)){
				$mas_3 = $admin_obj->mas_2($mas_2);
				$n = count($mas_3);			
					for($i = 0; $i < $n; $i++){					
					  if( (isset($_GET['gamer_id'])) and($_GET['gamer_id'] == $mas_3[$i])){				  
						$f3 = false;
						break;
					}
				}
			}
			$mas_minus_1 = $gamers_obj->minus_level($identuficator);
			if (isset($mas_minus_1)){
				$mas_minus_2 = $gamers_obj->minus_level($mas_minus_1);
			}
			if (isset($mas_minus_2)){
				$mas_minus_3 = $gamers_obj->minus_level($mas_minus_2);						
			}*/
			
			$mas_minus_1 = $gamers_obj->minus_level($identuficator);
			if (isset($mas_minus_1)){
				$mas_minus_2 = $gamers_obj->minus_level($mas_minus_1);
			}
			if (isset($mas_minus_2)){
				$mas_minus_3 = $gamers_obj->minus_level($mas_minus_2);						
			}
			
			if (isset($mas_minus_3) and ($mas_minus_3 != 0))
				$gamers_obj->minus($mas_minus_3, $_SESSION['user']['privilege'],$_SESSION['user']['id']);
			if (isset($mas_minus_2) and ($mas_minus_2 != 0))
				$gamers_obj->minus($mas_minus_2, $_SESSION['user']['privilege'],$_SESSION['user']['id']);
			if (isset($mas_minus_1) and ($mas_minus_1 != 0))
				$gamers_obj->minus($mas_minus_1, $_SESSION['user']['privilege'],$_SESSION['user']['id']);
			
			$gamers_obj->zero($identuficator,$_SESSION['user']['privilege'],$_SESSION['user']['id']);
			
			if ($f3){
				echo '<div class="two">';
				$first_level_mas = $gamers_obj->child($identuficator);
				for ($i=0;$i<3;$i++){
					if (isset($first_level_mas[$i]))
						$gamers_obj->first_level($first_level_mas[$i],$_SESSION['user']['privilege'],$_SESSION['user']['id']);
					else{
						if (!isset($_GET['gamer_id']))
							$_GET['gamer_id'] = $_SESSION['user']['id'];
							$gamers_obj->free_first_level($_SESSION['user']['id'],$_GET['gamer_id'],$_SESSION['user']['privilege']);
						}
					}
				echo '</div>';
				}
					
			$j = 0;
			if (($f3)and ($f2)){
				while ($j != 3)
				{
					if (isset($first_level_mas[$j])){
						echo '<div class="three">';
						$second_level_mas = $gamers_obj->child($first_level_mas[$j]);
						for ($i=0;$i<3;$i++){
							if (isset($second_level_mas[$i]))
								$gamers_obj->second_level($second_level_mas[$i],$_SESSION['user']['privilege']);
							else
							{
								if (isset($first_level_mas[$j]))
									$gamers_obj->free_second_level($_SESSION['user']['id'],$first_level_mas[$j],$_SESSION['user']['privilege']);
							}
						}
					}
					echo '</div>';
					$j++;
				}	
			}
					} else {
						
					if (!isset($_GET['gamer_id']))
						$identuficator = $_SESSION['user']['id'];
					else
						$identuficator = $_GET['gamer_id'];	
						
					if (isset($_POST['find_pyramid']) && ($gamers_obj->is_gamer((int)$_POST['find_pyramid'])))
						$identuficator = (int)$_POST['find_pyramid'];	
						
						$mas_minus_1 = $gamers_obj->minus_level($identuficator);
						if (isset($mas_minus_1)){
							$mas_minus_2 = $gamers_obj->minus_level($mas_minus_1);
						}
						if (isset($mas_minus_2)){
							$mas_minus_3 = $gamers_obj->minus_level($mas_minus_2);						
						}
						if (isset($mas_minus_3) and ($mas_minus_3 != 0))
							$gamers_obj->minus($mas_minus_3, $_SESSION['user']['privilege'],$_SESSION['user']['id']);
						if (isset($mas_minus_2) and ($mas_minus_2 != 0))
							$gamers_obj->minus($mas_minus_2, $_SESSION['user']['privilege'],$_SESSION['user']['id']);
						if (isset($mas_minus_1) and ($mas_minus_1 != 0))
							$gamers_obj->minus($mas_minus_1, $_SESSION['user']['privilege'],$_SESSION['user']['id']);
						
						
						
					$gamers_obj->zero($identuficator,$_SESSION['user']['privilege'],$_SESSION['user']['id']);
			
					echo '<div class="two">';
					$first_level_mas = $gamers_obj->child($identuficator);
					for ($i=0;$i<3;$i++){
						if (isset($first_level_mas[$i]))
							$gamers_obj->first_level($first_level_mas[$i],$_SESSION['user']['privilege'],$_SESSION['user']['id']);
						else{
							if (!isset($_GET['gamer_id']))
								//$_GET['gamer_id'] = $gamers_obj->top_pyramid();
								$_GET['gamer_id'] = $_SESSION['user']['id'];
								$gamers_obj->free_first_level($_SESSION['user']['id'],$_GET['gamer_id'],$_SESSION['user']['privilege']);
							}
						}
					echo '</div>';
				
					
					$j = 0;
					
						while ($j != 3)
						{
							if (isset($first_level_mas[$j])){
								echo '<div class="three">';
								$second_level_mas = $gamers_obj->child($first_level_mas[$j]);
								for ($i=0;$i<3;$i++){
									if (isset($second_level_mas[$i]))
										$gamers_obj->second_level($second_level_mas[$i],$_SESSION['user']['privilege']);
									else
									{
										if (isset($first_level_mas[$j]))
											$gamers_obj->free_second_level($_SESSION['user']['id'],$first_level_mas[$j],$_SESSION['user']['privilege']);
									}
								}
							}
							echo '</div>';
							$j++;
						}	
					
					}?>		
			</div>		
		<? endif;?>
		
		<?php if (isset($_GET['action']) && ($_GET['action']=='new_password')):?>
			<h3> Новый пароль</h3>
			<div class="reg">
				<form action="" method="post" class="reg">
					<p><label for="old_password">Старый пароль</label><input type="password" name="old_password" id="old_password" maxlength="255"/></p>
					<p><label for="password_upd">Новый пароль</label><input type="password" name="password_upd" id="password_upd" maxlength="255"/></p>
					<p><label for="confirm_upd">Подтверждение</label><input type="password" name="confirm_upd" id="confirm_upd" maxlength="255"/></p>
					<input type="button" value="Применить" id="pass-update">
				</form>			
			</div>	
		<? endif;?>
		
		
		<?php if (isset($_GET['action']) && ($_GET['action']=='cabinet')):?>
		
		<h3> Здраствуйте, <? echo $_SESSION['user']['login']?></h3>
		<div class="reg">
		<?$image = $users_obj->select_image($_SESSION['user']['id']);
		//if ($image)://?>
		
			<div id="img_user">
				<img class="image" src="<?echo $users_obj->image($image);?>"/>
			</div>
		<? //endif;?>
		
			<!--<script/ type="text/javascript"  src="../template/js/upload.js"></script>-->
			<form action="" method="post" class="reg">
				<p><label for="id">id</label><input type="text" value="<? echo $_SESSION['user']['id'];?>" name="login_upd" id="id" readonly maxlength="255"/></p> 
				<p><label for="login_upd">Логин</label><input type="text" value="<? echo $_SESSION['user']['login'];?>" name="login_upd" id="login_upd" readonly maxlength="255"/></p>
				<!--<p><label for="password_upd">Пароль</label><input type="password" name="password_upd" id="password_upd" maxlength="255"/></p>
				<p><label for="confirm_upd">Подтверждение</label><input type="password" name="confirm_upd" id="confirm_upd" maxlength="255"/></p>-->
				<p><label for="name_upd">Имя</label><input type="text" value="<? echo $_SESSION['user']['name'];?>" name="name_upd" id="name_upd" maxlength="255"/></p>
				<p><label for="surname_upd">Фамилия</label><input type="text" value="<? echo $_SESSION['user']['surname'];?>" name="surname_upd" id="surname_upd" maxlength="255"/></p>		
				<p><label for="phone_upd">Номер телефона</label><input type="text" value="<? echo $_SESSION['user']['phone'];?>" name="phone_upd" id="phone_upd" maxlength="255"/></p>
				<p><label for="email_upd">email</label><input type="text" value="<? echo $_SESSION['user']['email'];?>" name="email_upd" id="email_upd" readonly maxlength="255"/></p>
				<p><label for="country_upd">Страна</label><select name="country_upd" id="country_upd"><option value="<? echo $_SESSION['user']['country'];?>"><? echo $core_obj->value_country($_SESSION['user']['country'])?></option><?php  echo $location_obj->getCountries();?></select></p>
				<p><label for="city_upd">Город</label><select name="city_upd" class="pro" id="city_upd"><? echo $core_obj->value_city($_SESSION['user']['country'],$_SESSION['user']['city'])?></select></p>
				<p><label for="question_upd">Контрольный вопрос</label><select name="question_upd" id="question_upd" maxlength="255"><option value="<? echo $_SESSION['user']['question'];?>" checked="checked"><? echo $core_obj->value_question($_SESSION['user']['question'])?></option><?echo $core_obj->getQuestion()?></select></p>
				<p><label for="response_upd">Контрольний ответ</label><input type="text" value="<? echo $_SESSION['user']['response'];?>" name="response_upd" id="response_upd" maxlength="255"/></p>
				<input type="button" value="Редактировать" id="user-update">
			</form>			
		</div>	
	<?endif; ?>	
	
	<? if ((isset($_GET['action'])) and ($_GET['action'] == 'complain')):?>
		<div class="profile">
				<form action="" method="get">
					<p><h3>Напишите письмо Администратору</h3></p>
					<p><textarea id="elm1" name="elm1" rows="15" cols="80" style="max-width: 600px" class="tinymce">							
					</textarea></p>					
					<p><input type="button" value="Написать администратору" id="send_complain"></p>
				</form>
			</div>
	<? endif;?>
	
	
		<?php if (isset($_GET['action']) && ($_GET['action']=='distribute') && (!isset($_GET['id_user']))) 
			echo $res = $gamers_obj->distribute($_SESSION['user']['id']);
			
			if ((isset($_GET['action'])) && ($_GET['action']=='distribute') && (isset($_GET['id_user']))):?>
				<? $res = $admin_obj->select_user($_GET['id_user']);?>				
				<div class="reg">
					<form action="" method="post" class="reg">
						<p><label for="upd_login">Логин</label><input type="text" value="<? echo $res['login'];?>" name="upd_login" id="upd_login" readonly maxlength="255"/></p>
						<p><label for="upd_name">Имя</label><input type="text" value="<? echo $res['name'];?>" name="upd_name" id="upd_name" maxlength="255"/></p>
						<p><label for="upd_surname">Фамилия</label><input type="text" value="<? echo $res['surname'];?>" name="upd_surname" id="upd_surname" maxlength="255"/></p>		
						<p><label for="upd_phone">Номер телефона</label><input type="text" value="<? echo $res['phone'];?>" name="upd_phone" id="upd_phone" maxlength="255"/></p>
						<p><label for="upd_email">email</label><input type="text" value="<? echo $res['email'];?>" name="upd_email" id="upd_email" readonly maxlength="255"/></p>
						<p><label for="upd_country">Страна</label><select name="upd_country" id="upd_country"><option selected value="<? echo $res['country'];?>"><? echo $core_obj->value_country( $res['country'])?></option><?php echo $location_obj->getCountries();?></select></p>
						<p><label for="upd_city">Город</label><select name="upd_city" class="pro" id="upd_city"><option value="<? echo $res['city'];?>"><? echo $core_obj->value_city($res['country'], $res['city'])?></option></select></p>
						<p><label for="upd_question">Контрольный вопрос</label><select name="upd_question" id="upd_question" maxlength="255"><option value="<? echo $res['question'];?>" checked="checked"><? echo $core_obj->value_question($_SESSION['user']['question'])?></option><?echo $core_obj->getQuestion()?></select></p>
						<p><label for="upd_response">Контрольный ответ</label><input type="text" value="<? echo $res['response'];?>" name="upd_response" id="upd_response" maxlength="255"/></p>
						<input type="button" value="Распределить" id="distribute">
					</form>			
				</div>
				
			
				<div class="parent">
					<? echo $gamers_obj->check_parent($_SESSION['user']['id']);?>
				</div>
	<? endif;?>
	
	<?php if (isset($_GET['action']) and ($_GET['action']=='message') and (!isset($_GET['id_mes']))) 
			echo $users_obj->show_message($_SESSION['user']['id']);
		?>
		
		<?php if (isset($_GET['action']) and ($_GET['action']=='message') and (isset($_GET['id_mes']))) :?>
			<? $from = $users_obj->dataUser($_GET['from']);
			   $to = $users_obj->dataUser($_GET['to']);
			   $data_mes = $users_obj->data_message($_GET['id_mes']);
			   if (($data_mes['toReaded'] == 0) and ($_GET['to'] == $_SESSION['user']['id']))
				$users_obj->toReaded($_GET['id_mes']); ?>
			   
			<div class='r_message'>
				<p>От кого: <? echo $from['name'].' '.$from['surname'];
				echo ' &lt'.$from['email'].'&gt'; ?> </p>
				<p>Кому: <? echo ' &lt'. $to['email'].'&gt';?></p>	
				<p> <? echo date('H:i:s, d.m.Y',strtotime($data_mes['date']));?></p>
				<p>Тема: <? if ($data_mes['theme'] == '')
								$data_mes['theme'] = 'Без темы';
							echo $data_mes['theme'];?></p>
				<form action='' method='post'>
					<input type="hidden"  value="<? echo $from['login']?>" name="from" id="from"/>
					<input type="hidden"  value="<? echo $_GET['from'];?>" name="id_to" id="id_to"/>
					<p><label for='text'>Текст</label></p><textarea id='text' name=text><? echo $data_mes['text'];?></textarea>
					<? if ($from['id'] != $_SESSION['user']['id']) :?>
						<input type="button"  value="Ответить" name="answer" id="answer"/>
					<? endif;?>
				</form>
			</div>		
		<? endif;?>
		
		<? if (isset($_GET['action']) and ($_GET['action']=='trash') and (!isset($_GET['id_mes']))) :?>
			<? echo $users_obj->show_trash($_SESSION['user']['id']);?>
		<? endif;?>
		
	
		<?php if (isset($_GET['action']) && ($_GET['action']=='child') && (!isset($_GET['id_child'])))
				echo $gamers_obj->subordinates($_SESSION['user']['id']);	

			if (isset($_GET['action']) && ($_GET['action']=='child')&& (isset($_GET['id_child']))):?>
				<div class="profile">
				<?$res = $admin_obj->select_user($_GET['id_child']);
					$image = $users_obj->select_image($_GET['id_child']);
					if ($image):?>
						<ul id="image-list">
							<li class="user_image"><img src="<?echo $users_obj->image($image);?>"/> </li>
						</ul>	
					<? endif;?>
				
					<form action="" method="post" class="reg">
						<p><label>Логин</label><input type="text" value="<? echo $res['login'];?>" readonly maxlength="255"/></p>
						<p><label>Имя</label><input type="text" value="<? echo $res['name'];?>" readonly maxlength="255"/></p>
						<p><label>Фамилия</label><input type="text" value="<? echo $res['surname'];?>" readonly maxlength="255"/></p>		
						<p><label>Номер телефона</label><input type="text" value="<? echo $res['phone'];?>" readonly maxlength="255"/></p>
						<p><label>email</label><input type="text" value="<? echo $res['email'];?>" readonly maxlength="255"/></p>
						<p><label>Страна</label><input type="text" value="<? echo $core_obj->value_country($res['country'],$res['country']);?>" readonly maxlength="255"/></p>
						<p><label>Город</label><input type="text" value="<? echo $core_obj->value_city_show($res['city'])?>" readonly maxlength="255"/></p>			
						<p><label for="payd">Участник прошел уровень</label><input type="checkbox" name="payd" id="payd" value="0" <?  if($gamers_obj->is_payd($_GET['id_child'])):?>checked disabled<? endif;?> maxlength="255"/></p>
					</form>			
				</div>
	<? endif;?>
	</section>
	<footer>
		<div class="in_footer">
			<span class="copy">(c)kdsflkd fkdlkd dfkdflkkf.</span>
			<span class="text">djdkjd ddjdjd erlljker kf;sdks; k</span>
		</div>
	</footer>
	</body>
	</html>